{template '_header'}
<div class="page-header">
    当前位置：<span class="text-primary">门店商品管理</span>
</div>
<div class="page-content" style="display: block;">
    <form action="./index.php" method="get" class="form-horizontal form-search" role="form">
        <input type="hidden" name="c" value="site" />
        <input type="hidden" name="a" value="entry" />
        <input type="hidden" name="m" value="mx_shop" />
        <input type="hidden" name="do" value="web" />
        <input type="hidden" name="r" value="store.goods" />
        <input type="hidden" name="id" value="{$id}" />
        <div class="page-toolbar">
            <div class="col-sm-6">
                {ifp 'store.goods.add'}
                <a class="btn btn-primary btn-sm" data-toggle="ajaxModal"  href="{php echo webUrl('store/goods/plusgoods',array('id'=>$id));}">添加商品</a>
                <a class="btn btn-primary btn-sm" data-toggle="ajaxModal"  href="{php echo webUrl('store/goods/plusgoodsgroup',array('id'=>$id));}">添加商品组</a>
                {/if}
            </div>
            <div class="col-sm-6 pull-right">
                <div class="input-group">
                    <div class="input-group-select">
                        <select name="goodsgroupid" style="width: 150px" class='form-control' >
                            <option value="" >按商品组搜索</option>
                            {loop $grouplist $row}
                            <option value="{$row['id']}" {if $_GPC['goodsgroupid'] == $row['id']} selected="selected" {/if}>{$row['name']}</option>
                            {/loop}
                        </select>
                    </div>
                    <input type="text" class=" form-control" name='keyword' value="{$_GPC['keyword']}" placeholder="商品名称">
                    <span class="input-group-btn">
                        <button class="btn btn-primary" type="submit"> 搜索</button>
                    </span>
                </div>

            </div>
        </div>
    </form>
    {if count($list)>0}
    <table class="table table-hover table-responsive">
        {ifp 'store.goods.edit'}
        <div class="page-table-header">
            <input type="checkbox">
            <div class="btn-group" >
                <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle="batch" data-href="{php echo webUrl('store/goods/setstatus',array(status=>0))}" disabled="disabled">
                    <i class="icow icow-shangjia2"></i> 上架
                </button>
                <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle="batch" data-href="{php echo webUrl('store/goods/setstatus',array(status=>1))}" disabled="disabled">
                    <i class="icow icow-xiajia3"></i> 下架
                </button>
                <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle="batch-remove" data-confirm="确认要删除吗?" data-href="{php echo webUrl('store/goods/delete')}" disabled="disabled">
                    <i class="icow icow-shanchu1"></i> 删除
                </button>
            </div>
        {/if}
        </div>
        <thead class="navbar-inner">
        <tr>
            <th style="width:25px;"></th>
            <th style="width:60px;text-align:center;">排序</th>
            <th style="width:60px;">商品</th>
            <th>&nbsp;</th>
            <th>&nbsp;</th>
            <th style="width:90px;">价格</th>
            <th style="width:90px;">库存</th>
            <th style="width:60px;">状态</th>
            <th  {if $v['hasoption']} style="width: 75px;"{else}style="width: 75px;"{/if}>操作</th>
        </tr>
        </thead>
        <tbody>
        {loop $list $k $v}
        <tr>
            <td><input type='checkbox'   value="{$v['id']}" /></td>
            <td style="text-align:center;">
                <a href="javascript:;" data-toggle="ajaxEdit" data-href="{php echo webUrl('store/goods/setdisplayorder',array('id'=>$v['id']));}">{$v['sdisplayorder']}</a>
            </td>
            <td><img src="{php echo tomedia($v['thumb'])}" style="width:40px;height:40px;padding:1px;border:1px solid #ccc;" onerror="this.src='../addons/mx_shop/static/images/nopic.png'"></td>
            <td class="full" style="overflow-x: hidden;text-align: left">
                {$v['title']}
            </td>
            <td></td>
            <td>

                {if $v['hasoption']==1 && $v['type'] !=30}
                    {ifp 'goods.edit'}
                        <span data-toggle='tooltip' title='多规格不支持快速修改'>{$v['smarketprice']}</span>
                    {else}
                        {$v['smarketprice']}
                    {/if}
                {elseif $v['type']==30}
                    {ifp 'goods.edit'}
                    <span data-toggle='tooltip' title='预约商品不支持快速修改'>{$v['smarketprice']}</span>
                    {else}
                    {$v['smarketprice']}
                    {/if}
                {else}
                    {ifp 'goods.edit'}
                        <a href="javascript:;" data-toggle="ajaxEdit" data-href="{php echo webUrl('store/goods/setprice',array('id'=>$v['id']));}">{php echo floatval($v['smarketprice']);}</a>
                    {else}
                        {$v['smarketprice']}
                    {/if}
                {/if}
            </td>
            <td>
                {if $v['hasoption']==1 && $v['type'] !=30}
                    {ifp 'goods.edit'}
                        <span data-toggle='tooltip' title='多规格不支持快速修改'>{$v['stotal']}</span>
                    {else}
                        {$v['stotal']}
                    {/if}
                {elseif $v['type']==30}
                    {ifp 'goods.edit'}
                    <span data-toggle='tooltip' title='预约商品无库存'>0</span>
                    {else}
                        0
                    {/if}
                {else}
                    {ifp 'goods.edit'}
                        <a href="javascript:;" data-toggle="ajaxEdit" data-href="{php echo webUrl('store/goods/settotal',array('id'=>$v['id']));}">{$v['stotal']}</a>
                    {else}
                        {$v['stotal']}
                    {/if}
                {/if}

            </td>
            <td style="overflow:visible;">
                <span class="label {if $v['gstatus']}label-primary{/if}" data-toggle="ajaxSwitch" data-confirm="{if $v['gstatus']}确认下架？{else}确认上架？{/if}" data-switch-refresh="true" data-switch-value="{$v['gstatus']}" data-switch-value0="0|下架|label label-default|{php echo webUrl('store/goods/setstatus',array('id'=>$v['id'],'status'=>0));}" data-switch-value1="1|上架|label label-success|{php echo webUrl('store/goods/setstatus',array('id'=>$v['id'],'status'=>1));}">{if $v['gstatus']}上架{else}下架{/if}</span>
            </td>
            <td style="overflow:visible;position:relative">
                {ifp 'store.goods.edit'}
                    <a class="btn btn-default btn-sm btn-op btn-operation" data-toggle="ajaxRemove" href="{php echo webUrl('store/goods/delete',array('id'=>$v['id']));}" data-confirm="确认删除此商品？">
                         <span data-toggle="tooltip" data-placement="top" title="" data-original-title="删除">
                             <i class='icow icow-shanchu1'></i>
                        </span>
                    </a>

                    {if $v['hasoption']}
                        <a class="btn btn-default btn-sm btn-op btn-operation" href="{php echo webUrl('store/goods/goodsoption',array('id'=>$v['id']));}" >
                            <span data-toggle="tooltip" data-placement="top" title="" data-original-title="规格">
                                 <i class='icow icow-bianji2'></i>
                            </span>
                        </a>
                    {/if}

                {/if}
            </td>
        </tr>
        {/loop}
        </tbody>
        <tfoot>
            <tr>
                <td><input type="checkbox"></td>
                <td colspan="3">
                    <div class="btn-group" >
                        <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle="batch" data-href="{php echo webUrl('store/goods/setstatus',array(status=>0))}" disabled="disabled">
                            <i class="icow icow-shangjia2"></i> 上架
                        </button>
                        <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle="batch" data-href="{php echo webUrl('store/goods/setstatus',array(status=>1))}" disabled="disabled">
                            <i class="icow icow-xiajia3"></i> 下架
                        </button>
                        <button class="btn btn-default btn-sm btn-operation" type="button" data-toggle="batch-remove" data-confirm="确认要删除吗?" data-href="{php echo webUrl('store/goods/delete')}" disabled="disabled">
                            <i class="icow icow-shanchu1"></i> 删除
                        </button>
                    </div>
                </td>
                <td colspan="5" class="text-right">{$pager}</td>
            </tr>
        </tfoot>
    </table>
    {else}
    <div class='panel panel-default'>
        <div class='panel-body' style='text-align: center;padding:30px;'>
            暂时没有任何商品!
        </div>
    </div>
    {/if}
</div>
{template '_footer'}